package com.walter.learn.TestUtil;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

import static com.walter.learn.Util.FileUtils.fileToZip;
import static com.walter.learn.Util.FileUtils.getFilesList;

/**
 * @ProjectName: learnDemo
 * @Package: com.walter.util
 * @ClassName: FileUtilsTest
 * @Author: DELL
 * @Description: ${description}
 * @Date: 2019/8/14 20:12
 * @Version: 1.0
 */
public class FileUtilsTest {

    private static String resultType_Name = "name";
    private static String resultType_NameAbsolutePath = "absolutePath";
    /**
     * @Description 测试遍历文件
     * @Create 2019/8/14 20:10
     * @Author wangzheng
     */
    @Test
    public void testGetFilesList() {
        List<String> list = new ArrayList<>();
        getFilesList("E:\\imagesToWebp\\images", ".gif", resultType_Name, list);
        System.out.println(list.size());
    }

    /**
     * @Description 测试将文件打包成zip
     * @Create 2019/8/14 20:11
     * @Author wangzheng
     */
    @Test
    public void testFileToZip(){
        String sourceFilePath = "E:\\TestFileToZip\\Test";
        String zipFilePath = "E:\\TestFileToZip\\Test";
        String fileName = "3";
        boolean flag = fileToZip(sourceFilePath, zipFilePath, fileName);
        if (flag) {
            System.out.println("文件打包成功!");
        } else {
            System.out.println("文件打包失败!");
        }
    }
}
